﻿//You are given a sequence of positive integer values written into a string, separated by spaces.
//Write a function that reads these values from given string and calculates their sum.
//Example: string = "43 68 9 23 318" -> result = 461


using System;
using System.Collections.Generic;

public class SequenceOfPositiveIntegerValues
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Enter numbers separated by spaces!");
        string userInput = Console.ReadLine();
        string[] arrayOfStrings = userInput.Split(' ');
        int sum = 0;
        for (int i = 0; i < arrayOfStrings.Length; i++)
        {
            int value;
            int.TryParse(arrayOfStrings[i], out value);
            sum += value;
        }

        Console.WriteLine("Sum of numbers is {0}", sum);
    }
}
